// 作业:一,能不能使用promise的异步函数,封装下数据库的查询
let mysql=require('mysql');
let connection=mysql.createConnection({host:'127.0.0.1',user:'root',password:'root',database:'user_table'});
connection.connect();
let select='select * from user';
connection.query(select,(err,data)=>{
    console.log("----查询操作----");
    // console.log(err);
    console.log(data);//返回数组
});
let result=new Promise((resolve,rejects)=>{
    setTimeout(()=>{
        resolve(select+"查询成功");
        rejects(select+"查询成功")
    },2000);
   
}).then((value)=>{
    console.log(value);
}).catch((err)=>{
    console.log("异常"+err);
});
connection.end();


